Implementing Union-Find Algorithm with Base SAS DATA Steps and Macro Functions
نویسنده
چکیده
Union-Find algorithm is a classic algorithm used to form the union of disjoined sets and find connected components of a graph from a given set of vertices and edges. The algorithm is often used in data manipulations that involve graphs, trees, hierarchies, and linked networks. A tree data structure can be used to implement the algorithm. A SAS data set is a tuple data structure that is excellent for table manipulations, but cannot be directly applied for implementing Union-Find algorithm. In this paper, we will discuss the programming techniques that are available in Base SAS for the implementation of the Union-Find algorithm. We will explain how to implicitly represent graphs and trees using SAS arrays, and how to build hierarchical trees and perform queries on trees using SAS DATA steps and macro functions. We will also discuss the programming techniques that have been used to minimize average running time of the algorithm.
منابع مشابه
159-2011: Perl Regular Expression in SAS® Macro Programming
In this paper, the Perl regular expression facility that provides a concise and flexible means for matching strings of text is extended to the macro environment using three new macro functions. Consequently, this allows direct pattern matching and replacement in macro variables, facilitating the construction of flexible and customized functions through internally parsing patterned inputs. This ...
متن کاملReading Between the Lines: Distinguishing Macro Code from Open Code in Macros
Have you ever been confused by the sight of bad “SAS® grammar” such as statements that read %IF &X=A %THEN IF X=A...? Have you ever puzzled over how to iteratively generate DATA step DO loops or parts of them? Ever wonder why macros sometimes contain consecutive semicolons? If so, you are not alone. The macro facility enables us to generate open code that varies with circumstances, but of cours...
متن کامل105-2008: Using the SAS® DATA Step and PROC SQL to Create Macro Arrays
Successful analysis in SAS often requires lengthy repetitive steps; the same code is executed on numerous data points. Iteration of SAS code is often easily achieved with the use of Macro Arrays. The programmer can employ numerous methods for creating these arrays, as well as choosing among different structural designs. PROC SQL and the SAS DATA step can each provide clear advantages to the cre...
متن کاملA SAS/JMP Integration for Implementation of a Clustering Algorithm for High Dimensional Low Sample Size Data
A SAS macro solution is presented for clustering of high dimensional low sample size (HDLLSS) data using a new algorithm based o p-values as similarity measure. The algorithm PPCLUST was developed by von Borries (2008) and implemented using SAS macro language with the macro autocall facility and window macro command for friendly interface. The SAS interface to JMP was used to run a SAS macro in...
متن کاملQuickSorting An Array
The article is a walk through a DATA step implementation of one of the most versatile, fast, and well-rounded sorting algorithms Quicksort. Although a need in array sorting frequently arises in practical SAS programming, Base SAS does not provide a function or call routine to serve the purpose. However, the SAS Language is flexible and powerful enough to implement just about any algorithm. In t...
متن کامل